<template>
    <div class="container">
        <div class="page-header">
            <h1>搜索 <small>正在搜索中...请稍后...</small></h1>
        </div>
    </div>
</template>

<script>
export default {
  name:'search',
  mounted() {
    let keyword = this.$route.params.keyword
    this.$axios.post(
      '/commodity/query',
      this.$qs.stringify({
        // keyword: this.$route.query.keyword
        keyword: keyword
      })
    ).then((res) => {
      console.log('/commodity/query' + ' 获取成功...')
      console.log(res.data)
      this.$store.commit('updateSearch', res.data)
      let that = this
      setTimeout(() => {
        that.$router.push({ path: '/search/' + ((keyword != null && keyword.length > 0) ? keyword : '') })
      }, 1000)
    }).catch(function (error) {
      console.log('/commodity/query 获取失败...')
      console.log(error)
    })
  }
}
</script>

<style>

</style>
